package com.hst.capacity.domain.model.entity;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 抽象实体，自带审计字段。
 *
 * */
@Data
@MappedSuperclass
public abstract class AbstractEntity implements Serializable {

    @Column(updatable = false, length = 50)
    private  String createBy;

    @CreationTimestamp
    @Column(updatable = false)
    private LocalDateTime createTime;

    @Column(insertable = false, length = 50)
    private  String updateBy;

    @UpdateTimestamp
    @Column(insertable = false)
    private LocalDateTime updateTime;

    public AbstractEntity() {
        this.createBy = "system";
    }
}
